class Role:
    def __init__(self, name, HP, MP):
        self.name = name
        self.HP = HP
        self.MP = MP

    def __str__(self):
        return self.name, '现有血量:', self.HP, ':蓝量:', self.MP

    def hit(self):
        return 2

    def Q(self):
        self.MP -= 10
        return 10

    def W(self):
        self.HP -= 5
        return 10


class Monster:
    def __init__(self, HP):
        self.HP = HP

    def hit(self):
        return 5

    def __str__(self):
        return '怪物血量:', self.HP


class Fight:
    def fight(self, RE, MO):
        while True:
            inp = input('请输入操作')
            if 'Q' == inp:
                MO.HP -= RE.Q()
            elif 'W' == inp:
                MO.HP -= RE.W()
            elif 'exit' == inp:
                break
                MO.HP -= RE.hit()
            RE.HP -= MO.hit()
            print(RE.__str__())
            print(MO.__str__())
            if MO.HP <= 0:
                print('胜利')
                break
            elif RE.HP <= 0:
                print('失败')
                break


tqq = Role('tqq', 100, 200)
m = Monster(200)
f = Fight()
f.fight(tqq, m)
